package com.fadadianqi.logistics.admin.net;

import com.fadadianqi.logistics.admin.net.handler.*;

public class ChannelHandlerFactory {

    public static ChannelHandler<?> getNewHandler(Packet packet) {
        int action = packet.getHead().getAction();
        ChannelHandler<?> handler = null;
        switch (action) {
            case Action.KEEP_ALIVE:
                handler = new KeepAliveHandler();
                break;
            case Action.KEEP_ALIVE_ACK:
                handler = new KeepAliveAckHandler();
                break;
            case Action.SMS_PACKET:
                handler = new SMSHandler();
                break;
            case Action.SMS_PACKET_ACK:
                handler = new SMSAckHandler();
                break;
            case Action.CLOSE_CONNECTION:
                handler = new CloseConnectionHandler();
                break;
        }
        return handler;
    }

}
